<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexpcController extends HomeController {

    //系统首页
    public function indexpc(){

        $category = D('Category')->getTree();
        $lists    = D('Document')->lists(null);

        $this->assign('category',$category);//栏目
        $this->assign('lists',$lists);//列表
        $this->assign('page',D('Document')->page);//分页
        $this->display();
    }
    
    //行情新闻
    public function newspc(){
        $resu = array('code' => 1,'msg' => '行情新闻查询成功!','data' => array());
        $dt = M('document')
            ->alias('d')
            ->join('lz88_picture as p ON p.id = d.cover_id')
            ->field('p.path,d.title,d.id')
            ->select();
        if($dt){
            $resu['data'] = $dt;
            echo $resu;
        }else{
            $resu['msg'] = '行情新闻查询失败!';
            echo $resu;
        }
        $this -> display();
    }
    //行情新闻详情
    public function news_detailspc(){
        $resu = array('code' => 1,'msg' => '行情新闻详情查询成功!','data' => array());
        $dt = M('document')
            ->alias('d')
            ->join('lz88_picture as p ON p.id = d.cover_id')
            ->join('lz88_document_article as e ON e.id = d.id')
            ->where(array('d.id'=>$_POST['id']))
            ->field('p.path,e.content,d.title')
            ->find();
        if($dt){
            $resu['data'] = $dt;
            echo $resu;
        }else{
            $resu['msg'] = '行情新闻详情查询失败!';
            echo $resu;
        }
        $this -> display();
    }
    //价格表
    public function shujupc(){
        $resu = array('code' => 1,'msg' => '数据发送成功!','data' => array());
        $dt = M('price')->select();
        $resu['data'] = $dt;
        echo $resu;
        $this -> display();
    }
    //折线图
//    public function zhexiantupc(){
//        /*//$resu = array('code' => 1,'msg' => '数据发送成功!','data' => array());
//        //$list = M('data_table')->field('color,dates,data,volumes')->select();
//        $list = M('data_table')->field('color')->select();
//        $data = implode($list);
//        //var_dump($data);exit;
//        /*$data = explode("|",$list);
//        $vvv = implode("|",$list);
//        var_dump($list);exit;
//        parse_str("name=Bill&age=60",$myArray);
//
//        $resu['data'] = $list;
//        var_dump($list);
//        var_dump($myArray);exit;
//        //echo $resu;
//        $this -> display();*/
//
//            $resu = array('code' => 1,'msg' => '数据发送成功!','data' => array());
//
//
//            $zhexian = array(['2015/7/21','3939.9','4017.67','25.57','0.64%','3912.8','4041.82','504288000','64641684','-'],['2015/7/20','3948.42','3992.11','34.76','0.88%','3927.12','4021.33','539106688','68825560']);
//            $riqi = [86160000,79330000,102600000,104890000,85230000,115230000,99410000,90120000,79990000,107100000,81020000,91710000,84510000,118160000,89390000,89820000,100210000,102720000,134120000];
//            $shuzhuang =  ["2016-03-29", "2016-03-30", "2016-03-31", "2016-04-01", "2016-04-04", "2016-04-05", "2016-04-06", "2016-04-07", "2016-04-08", "2016-04-11", "2016-04-12", "2016-04-13", "2016-04-14", "2016-04-15"];
//            $array = array($zhexian,$riqi,$shuzhuang);
//            $resu['data'] = $array;
//            $this -> ajaxReturn($resu);
//
//    }
    //公司名称
    public function companypc(){
        $resu = array('code' => 1,'msg' => '公司名称查询成功!','data' => array());
        $dt = M('company');
        $data = $dt->field('companyname')->select();

        if($data){
            $resu['data'] = $data;
            echo $resu;
        }else{
            $resu['msg'] = '公司名称查询失败!';
            echo $resu;
        }
        $this -> display();
    }
}